<form class="layui-form layui-card" action="{:request()->url()}" data-auto="true" method="post" autocomplete="off">
    <div class="layui-card-body">

        <div class="layui-form-item">
            <label class="layui-form-label">店员编号</label>
            <div class="layui-input-block">
                <input name="number" value='{$vo.number|default=""}' required placeholder="请输入设备名称" class="layui-input">
                <p class="help-block"></p>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">店员名称</label>
            <div class="layui-input-block">
                <input name="name" value='{$vo.name|default=""}' required placeholder="请输入设备ID"
                       class="layui-input">
                <p class="help-block"></p>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">性别</label>
            <div class="layui-input-block">
                <input type="radio" name="sex" value="1" title="男" {if isset($vo.sex) && $vo.sex==1 }checked{/if}>
                <input type="radio" name="sex" value="2" title="女" {if isset($vo.sex) && $vo.sex==2 }checked{/if}>
                <p class="help-block"></p>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">头像</label>
            <div class="layui-input-block">
                <input type="text" name="portrait" hidden>
                <a data-file data-file='one' data-type='png,jpg,gif' data-size='5242880'
                   data-type="png,jpg" data-field="portrait" class="layui-btn  layui-btn-normal layui-btn-sm">上传文件</a>
                <div id="tu" style="padding-top: 20px; {if empty($vo['portrait'])} display: none {/if} ">
                    <img id="images" width="50px" height="50px" src="{$vo['portrait']|default=''}">
                </div>
                <p class="help-block"></p>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">门店</label>
            <div class="layui-input-block">
                <select name="shop_id" lay-filter="distributor" lay-search required>
                    <option value="">请选择</option>
                    {volist name="distributor" id="v"}
                    <option value="{$key}" {if isset($vo.shop_id) && $key== $vo.shop_id} selected {/if}>{$v}</option>
                    {/volist}
                </select>
                <p class="help-block"></p>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">联系电话</label>
            <div class="layui-input-block">
                <input name="phone" value='{$vo.phone|default=""}' required placeholder="请输入联系电话" class="layui-input">
                <p class="help-block"></p>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">岗位</label>
            <div class="layui-input-block">
                <input name="position" value='{$vo.position|default=""}' placeholder="请输入岗位" class="layui-input">
                <p class="help-block"></p>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">管理职务详情</label>
            <div class="layui-input-block">
                <input name="work_detail" value='{$vo.work_detail|default=""}' placeholder="请输入管理职务详情" class="layui-input">
                <p class="help-block"></p>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">状态</label>
            <div class="layui-input-block">
                <input type="radio" name="status" value="1" title="正常" {if isset($vo.status) && $vo.status==1 }checked{/if}>
                <input type="radio" name="status" value="2" title="冻结" {if isset($vo.status) && $vo.status==2 }checked{/if}>
                <input type="radio" name="status" value="3" title="离职" {if isset($vo.status) && $vo.status==3 }checked{/if}>
                <p class="help-block"></p>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">是否白名单</label>
            <div class="layui-input-block">
                <input type="radio" name="is_special" value="1" title="是" {if isset($vo.is_special) && $vo.is_special==1 }checked{/if}>
                <input type="radio" name="is_special" value="2" title="否" {if isset($vo.is_special) && $vo.is_special==2 }checked{/if}>
                <p class="help-block"></p>
            </div>
        </div>
    </div>

    <div class="hr-line-dashed"></div>
    {notempty name='vo.id'}<input type='hidden' value='{$vo.id}' name='id'>{/notempty}

    <div class="layui-form-item text-center">
        <button class="layui-btn" type='submit'>保存数据</button>
        <button class="layui-btn layui-btn-danger" type='button' data-confirm="确定要取消编辑吗？" data-close>取消编辑</button>
    </div>
</form>
<script>
    form.render();
</script>

<script>
    $(function () {
        /*！捕获文件上传结果 */
        $('[name=portrait]').on('change', function () {
            // 文件地址变量事件
            if(this.value){
                $('#tu').show();
                $('#images').attr('src',this.value)
            }else{
                $('#tu').hide();
                $('#images').attr('src','')
            }
        });

        /*！文件上传过程事件处理 */
        $('[data-file]').on('upload.choose', function (files) {
            // 文件选择后的事件
        }).on('upload.hash', function (file) {
            // file 当前文件对象
        }).on('upload.progress', function (obj) {
            // obj.file 当前文件对象
            // obj.event 文件上传进度事件
            // obj.number 当前上传进度值
        }).on('upload.done', function (obj) {
            // obj.file 当前完成的文件对象
            // obj.data 当前文件上传后服务端返回的内容
        }).on('upload.complete', function () {
            // 全部文件上传成功
        })
    });
</script>



